Optimal. Leaf size=131 \[ (a c-b c-a d-b d) (a c+b c+a d-b d) x-\frac {2 (b c+a d) (a c-b d) \log (\cos (e+f x))}{f}+\frac {b \left (2 a c d+b \left (c^2-d^2\right )\right ) \tan (e+f x)}{f}+\frac {c d (a+b \tan (e+f x))^2}{f}+\frac {d^2 (a+b \tan (e+f x))^3}{3 b f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.13, antiderivative size = 131, normalized size of antiderivative = 1.00, number of steps
used = 4, number of rules used = 4, integrand size = 25, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.160, Rules used = {3624, 3609,
3606, 3556} \begin {gather*} \frac {b \left (2 a c d+b \left (c^2-d^2\right )\right ) \tan (e+f x)}{f}+\frac {c d (a+b \tan (e+f x))^2}{f}-\frac {2 (a d+b c) (a c-b d) \log (\cos (e+f x))}{f}+x (a c-a d-b c-b d) (a c+a d+b c-b d)+\frac {d^2 (a+b \tan (e+f x))^3}{3 b f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3556
Rule 3606
Rule 3609
Rule 3624
Rubi steps
\begin {align*} \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x))^2 \, dx &=\frac {d^2 (a+b \tan (e+f x))^3}{3 b f}+\int (a+b \tan (e+f x))^2 \left (c^2-d^2+2 c d \tan (e+f x)\right ) \, dx\\ &=\frac {c d (a+b \tan (e+f x))^2}{f}+\frac {d^2 (a+b \tan (e+f x))^3}{3 b f}+\int (a+b \tan (e+f x)) \left (-2 b c d+a \left (c^2-d^2\right )+\left (2 a c d+b \left (c^2-d^2\right )\right ) \tan (e+f x)\right ) \, dx\\ &=(a c-b c-a d-b d) (a c+b c+a d-b d) x+\frac {b \left (2 a c d+b \left (c^2-d^2\right )\right ) \tan (e+f x)}{f}+\frac {c d (a+b \tan (e+f x))^2}{f}+\frac {d^2 (a+b \tan (e+f x))^3}{3 b f}+(2 (b c+a d) (a c-b d)) \int \tan (e+f x) \, dx\\ &=(a c-b c-a d-b d) (a c+b c+a d-b d) x-\frac {2 (b c+a d) (a c-b d) \log (\cos (e+f x))}{f}+\frac {b \left (2 a c d+b \left (c^2-d^2\right )\right ) \tan (e+f x)}{f}+\frac {c d (a+b \tan (e+f x))^2}{f}+\frac {d^2 (a+b \tan (e+f x))^3}{3 b f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 1.13, size = 185, normalized size = 1.41 \begin {gather*} \frac {2 d^2 (a+b \tan (e+f x))^3+3 \left (2 a c d+b \left (-c^2+d^2\right )\right ) \left (i \left ((a+i b)^2 \log (i-\tan (e+f x))-(a-i b)^2 \log (i+\tan (e+f x))\right )-2 b^2 \tan (e+f x)\right )+6 c d \left ((i a-b)^3 \log (i-\tan (e+f x))-(i a+b)^3 \log (i+\tan (e+f x))+6 a b^2 \tan (e+f x)+b^3 \tan ^2(e+f x)\right )}{6 b f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.10, size = 189, normalized size = 1.44
method | result | size |
norman | \(\left (a^{2} c^{2}-a^{2} d^{2}-4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) x +\frac {\left (a^{2} d^{2}+4 a b c d +b^{2} c^{2}-b^{2} d^{2}\right ) \tan \left (f x +e \right )}{f}+\frac {b d \left (a d +b c \right ) \left (\tan ^{2}\left (f x +e \right )\right )}{f}+\frac {b^{2} d^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{3 f}+\frac {\left (a^{2} c d +a b \,c^{2}-a b \,d^{2}-b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{f}\) | \(162\) |
derivativedivides | \(\frac {\frac {b^{2} d^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{3}+a b \,d^{2} \left (\tan ^{2}\left (f x +e \right )\right )+b^{2} c d \left (\tan ^{2}\left (f x +e \right )\right )+a^{2} d^{2} \tan \left (f x +e \right )+4 a b c d \tan \left (f x +e \right )+b^{2} c^{2} \tan \left (f x +e \right )-b^{2} d^{2} \tan \left (f x +e \right )+\frac {\left (2 a^{2} c d +2 a b \,c^{2}-2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}-4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) | \(189\) |
default | \(\frac {\frac {b^{2} d^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{3}+a b \,d^{2} \left (\tan ^{2}\left (f x +e \right )\right )+b^{2} c d \left (\tan ^{2}\left (f x +e \right )\right )+a^{2} d^{2} \tan \left (f x +e \right )+4 a b c d \tan \left (f x +e \right )+b^{2} c^{2} \tan \left (f x +e \right )-b^{2} d^{2} \tan \left (f x +e \right )+\frac {\left (2 a^{2} c d +2 a b \,c^{2}-2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}-4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) | \(189\) |
risch | \(-\frac {4 i b^{2} c d e}{f}+\frac {4 i a b \,c^{2} e}{f}-2 i b^{2} c d x -\frac {4 i a b \,d^{2} e}{f}+a^{2} c^{2} x -a^{2} d^{2} x -4 a b c d x -b^{2} c^{2} x +b^{2} d^{2} x -2 i a b \,d^{2} x +\frac {4 i a^{2} c d e}{f}+2 i a b \,c^{2} x +\frac {2 i \left (-6 i a b \,d^{2} {\mathrm e}^{2 i \left (f x +e \right )}-6 i b^{2} c d \,{\mathrm e}^{2 i \left (f x +e \right )}+3 a^{2} d^{2} {\mathrm e}^{4 i \left (f x +e \right )}+12 a b c d \,{\mathrm e}^{4 i \left (f x +e \right )}+3 b^{2} c^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 b^{2} d^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 i a b \,d^{2} {\mathrm e}^{4 i \left (f x +e \right )}-6 i b^{2} c d \,{\mathrm e}^{4 i \left (f x +e \right )}+6 a^{2} d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+24 a b c d \,{\mathrm e}^{2 i \left (f x +e \right )}+6 b^{2} c^{2} {\mathrm e}^{2 i \left (f x +e \right )}-6 b^{2} d^{2} {\mathrm e}^{2 i \left (f x +e \right )}+3 a^{2} d^{2}+12 a b c d +3 b^{2} c^{2}-4 b^{2} d^{2}\right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}+2 i a^{2} c d x -\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a^{2} c d}{f}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a b \,c^{2}}{f}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) a b \,d^{2}}{f}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) b^{2} c d}{f}\) | \(465\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.56, size = 164, normalized size = 1.25 \begin {gather*} \frac {b^{2} d^{2} \tan \left (f x + e\right )^{3} + 3 \, {\left (b^{2} c d + a b d^{2}\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left (4 \, a b c d - {\left (a^{2} - b^{2}\right )} c^{2} + {\left (a^{2} - b^{2}\right )} d^{2}\right )} {\left (f x + e\right )} + 3 \, {\left (a b c^{2} - a b d^{2} + {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 3 \, {\left (b^{2} c^{2} + 4 \, a b c d + {\left (a^{2} - b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )}{3 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.63, size = 162, normalized size = 1.24 \begin {gather*} \frac {b^{2} d^{2} \tan \left (f x + e\right )^{3} - 3 \, {\left (4 \, a b c d - {\left (a^{2} - b^{2}\right )} c^{2} + {\left (a^{2} - b^{2}\right )} d^{2}\right )} f x + 3 \, {\left (b^{2} c d + a b d^{2}\right )} \tan \left (f x + e\right )^{2} - 3 \, {\left (a b c^{2} - a b d^{2} + {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 3 \, {\left (b^{2} c^{2} + 4 \, a b c d + {\left (a^{2} - b^{2}\right )} d^{2}\right )} \tan \left (f x + e\right )}{3 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 258 vs.
\(2 (117) = 234\).
time = 0.14, size = 258, normalized size = 1.97 \begin {gather*} \begin {cases} a^{2} c^{2} x + \frac {a^{2} c d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - a^{2} d^{2} x + \frac {a^{2} d^{2} \tan {\left (e + f x \right )}}{f} + \frac {a b c^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - 4 a b c d x + \frac {4 a b c d \tan {\left (e + f x \right )}}{f} - \frac {a b d^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} + \frac {a b d^{2} \tan ^{2}{\left (e + f x \right )}}{f} - b^{2} c^{2} x + \frac {b^{2} c^{2} \tan {\left (e + f x \right )}}{f} - \frac {b^{2} c d \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} + \frac {b^{2} c d \tan ^{2}{\left (e + f x \right )}}{f} + b^{2} d^{2} x + \frac {b^{2} d^{2} \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {b^{2} d^{2} \tan {\left (e + f x \right )}}{f} & \text {for}\: f \neq 0 \\x \left (a + b \tan {\left (e \right )}\right )^{2} \left (c + d \tan {\left (e \right )}\right )^{2} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 2258 vs.
\(2 (133) = 266\).
time = 1.28, size = 2258, normalized size = 17.24 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 5.28, size = 230, normalized size = 1.76 \begin {gather*} \frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a^2\,d^2+4\,a\,b\,c\,d+b^2\,c^2-b^2\,d^2\right )}{f}+\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (a^2\,c\,d+a\,b\,c^2-a\,b\,d^2-b^2\,c\,d\right )}{f}-\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a\,c+a\,d+b\,c-b\,d\right )\,\left (a\,d-a\,c+b\,c+b\,d\right )}{-a^2\,c^2+a^2\,d^2+4\,a\,b\,c\,d+b^2\,c^2-b^2\,d^2}\right )\,\left (a\,c+a\,d+b\,c-b\,d\right )\,\left (a\,d-a\,c+b\,c+b\,d\right )}{f}+\frac {b^2\,d^2\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3\,f}+\frac {b\,d\,{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (a\,d+b\,c\right )}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________